Prompting basics

Prompting a large language model.

Published

26 Feb, 2024

Pyobsplot demo

Code
import polars as pl
# from pyobsplot import Plot
# from pyobsplot import Plot, d3, Math, js
from pyobsplot import Obsplot, Plot, d3, js

opw = Obsplot(renderer="widget")
# opj = Obsplot(renderer="jsdom")

penguins = pl.read_csv("https://github.com/juba/pyobsplot/raw/main/doc/data/penguins.csv")
1
The renderer parameter can be set to "widget" or "jsdom". The former is the default and uses the ipywidgets library to render the plot in a Jupyter notebook. The latter uses the pywebview library to render the plot in a separate window.
2
The penguins dataset is a popular dataset from the palmerpenguins package in R. It contains measurements of penguins from three species: Adelie, Chinstrap, and Gentoo.
Code
penguins
shape: (344, 7)
species island culmen_length_mm culmen_depth_mm flipper_length_mm body_mass_g sex
str str f64 f64 f64 f64 str
"Adelie" "Torgersen" 39.1 18.7 181.0 3750.0 "MALE"
"Adelie" "Torgersen" 39.5 17.4 186.0 3800.0 "FEMALE"
"Adelie" "Torgersen" 40.3 18.0 195.0 3250.0 "FEMALE"
"Adelie" "Torgersen" NaN NaN NaN NaN null
"Adelie" "Torgersen" 36.7 19.3 193.0 3450.0 "FEMALE"
"Adelie" "Torgersen" 39.3 20.6 190.0 3650.0 "MALE"
"Adelie" "Torgersen" 38.9 17.8 181.0 3625.0 "FEMALE"
"Adelie" "Torgersen" 39.2 19.6 195.0 4675.0 "MALE"
"Adelie" "Torgersen" 34.1 18.1 193.0 3475.0 null
"Adelie" "Torgersen" 42.0 20.2 190.0 4250.0 null
"Adelie" "Torgersen" 37.8 17.1 186.0 3300.0 null
"Adelie" "Torgersen" 37.8 17.3 180.0 3700.0 null
"Gentoo" "Biscoe" 43.5 15.2 213.0 4650.0 "FEMALE"
"Gentoo" "Biscoe" 51.5 16.3 230.0 5500.0 "MALE"
"Gentoo" "Biscoe" 46.2 14.1 217.0 4375.0 "FEMALE"
"Gentoo" "Biscoe" 55.1 16.0 230.0 5850.0 "MALE"
"Gentoo" "Biscoe" 44.5 15.7 217.0 4875.0 null
"Gentoo" "Biscoe" 48.8 16.2 222.0 6000.0 "MALE"
"Gentoo" "Biscoe" 47.2 13.7 214.0 4925.0 "FEMALE"
"Gentoo" "Biscoe" NaN NaN NaN NaN null
"Gentoo" "Biscoe" 46.8 14.3 215.0 4850.0 "FEMALE"
"Gentoo" "Biscoe" 50.4 15.7 222.0 5750.0 "MALE"
"Gentoo" "Biscoe" 45.2 14.8 212.0 5200.0 "FEMALE"
"Gentoo" "Biscoe" 49.9 16.1 213.0 5400.0 "MALE"
Code
Plot.plot({
    "grid": True,
    "color": {"legend": True},
    "marks": [
        Plot.dot(
            penguins, 
            {"x": "flipper_length_mm", "y": "body_mass_g", "fill": "species"}
        ),
        Plot.density(
            penguins, 
            {"x": "flipper_length_mm", "y": "body_mass_g", "stroke": "species"}
        )
    ]
})
Code
data = pl.DataFrame({
    "x": [1, 5, 2, 4, 6, 2, 4],
    "y": [2, 1, 3, 4, 5, 1, 2],
    "type": ["T1", "T2", "T1", "T2", "T1", "T1", "T2"],
})

opw({
    "grid": True,
    "marks": [
        Plot.dot(data, {
            "x": "x", "y": "y", "r": 5,
            "stroke": "black", "fill": "steelblue",
            "fillOpacity": js("d => d.type == 'T1' ? 0.7 : 0.1")
        })
    ]
})
Back to top

Reuse

Citation

BibTeX citation:
@online{ellis2024,
  author = {Ellis, Andrew},
  title = {Prompting Basics},
  date = {2024-02-26},
  url = {https://virtuelleakademie.github.io/promptly-literate/pages/tutorial-basic-prompting.html},
  langid = {en}
}
For attribution, please cite this work as:
Ellis, Andrew. 2024. “Prompting Basics.” February 26, 2024. https://virtuelleakademie.github.io/promptly-literate/pages/tutorial-basic-prompting.html.